package com.rentcarRepair.controller.api;

import com.eight.pojo.TbMaintainRecord;
import com.eight.vo.ComResult;
import com.rentcarRepair.service.impl.maintainRecordServiceImpl;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.time.LocalDateTime;

/**
 * @author caoch
 * @since 2023/2/28 9:59
 **/
@RestController
@RequestMapping("rentcar-repair/api")
public class maintainRecordApiController {
	@Resource(name ="maintainRecordServiceImpl")
	private maintainRecordServiceImpl maintainRecordService;
	@RequestMapping("addRecord")
	public ComResult addRecord(@RequestBody TbMaintainRecord record) {
		record.setAddtime((LocalDateTime.now()));
		return new ComResult(2000,"success",maintainRecordService.addRecord(record));
	}
	@RequestMapping("updateRecord")
	public ComResult updateRecode(@RequestBody TbMaintainRecord record) {
		return new ComResult(2000,"success",maintainRecordService.updateRecord(record));
	}
	@RequestMapping("removeRecord/{id}")
	public ComResult removeRecode(@PathVariable int id) {
		return new ComResult(2000,"success",maintainRecordService.removeRecord(id));
	}
	@RequestMapping("selectRecord")
	public ComResult selectRecode(@RequestParam(defaultValue = "1")Integer currentPage,
	                        @RequestParam(defaultValue = "5")Integer pageSize,
	                        @RequestBody TbMaintainRecord record ) {
		return new ComResult(2000,"success",maintainRecordService.selectRecord(currentPage, pageSize, record));
	}
}
